home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-09-03 | 7.0 KB | 174 lines |
- ' copperlist disassembly/save/both routines by Kyzer/CSG 30/1/96
- '
- ' NOTES: If you get a "MOVE #$xxxx,$xxxx" as opposed to a
- ' "MOVE #$xxxx,regname" then A) the copperlist is not a copperlist, B) the
- ' copperlist is damaged or C) some nutter thinks writing to undefined
- ' registers is cool. If nothing is printed/saved then tough luck! The
- ' copperlist doesn't end with a $FFFFFFFE like it should! Oh, and 151404
- ' bytes is the theoretic maximum length of a copperlist, but in reality
- ' it's impossible.
- '
- ' Demo of usage:
- Screen Open 0,640,256,4,Hires
- Screen Display 0,128,48,640,256
- ' ^ first, open a hires screen for fun
- '
- FINDMAINCOP : ADR=Param
- ' ^ get address of the AMOS master copperlist
- '
- COPDIS[ADR]
- ' ^ disassemble the copperlist to the screen.
- ' press any key to pause, then any key to continue
- '
- COPDIS_SAVE[ADR,"ram:copperlist1.txt"]
- ' ^ and disassemble again, but to the file "ram:copperlist1.txt"
- '
- COPSAVE[ADR,"ram:copperlist1.bin"]
- ' ^ save the copperlist as raw data
- '
- NAMEREG[$92] : A$=Param$
- ' ^ get name of register $92 (it's ddfstrt, btw :)
- '
- FINDCOPVALUE[ADR,$92] : A=Param
- Print A$;" =";A
- ' ^ find ddfstrt value in the copperlist, and print it
- '
- End
- '
- Procedure COPDIS[COPLIST]
- ' disassembles a copper list to screen
- '
- CEND=$FFFFFFFE : CL=COPLIST
- ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
- If Leek(ADR)<>CEND Then Pop Proc
- Repeat
- If Inkey$<>"" Then Wait Key
- INST=Leek(CL) : Add CL,4
- If Btst(16,INST)
- WA=INST : WB=INST : WC=INST : WD=INST
- Rol.l 8,WA : Rol.l 16,WB
- WA=WA and 255 : WB=WB and 255 : WC=WC and 65535
- A$="x="+Str$(WB)+",y="+Str$(WA)
- If INST=CEND
- Print Hex$(INST);": CEND"
- Else
- If Btst(0,WC) : C$="SKIP" Else C$="WAIT" : End If
- Print Hex$(INST);": ";C$;" ";A$-" "+" (mask="+(Hex$(WC)-" ")+")"
- End If
- Else
- MA=INST : MB=INST : Rol.l 16,MA
- MA=MA and 65535 : MB=MB and 65535
- NAMEREG[MA] : MA$=Param$
- If MA$=""
- Print Hex$(INST,8);": MOVE #";Hex$(MB);",";Hex$(MA)
- Else
- Print Hex$(INST,8);": MOVE #";Hex$(MB);",";MA$
- End If
- End If
- Until INST=CEND
- End Proc
- Procedure COPDIS_SAVE[COPLIST,FILENAME$]
- ' disassembles a copper list to a file
- '
- CEND=$FFFFFFFE : CL=COPLIST
- ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
- If Leek(ADR)<>CEND Then Pop Proc
- Open Out 1,FILENAME$ : N$=Chr$(10)
- Repeat
- INST=Leek(CL) : Add CL,4
- If Btst(16,INST)
- WA=INST : WB=INST : WC=INST : WD=INST
- Rol.l 8,WA : Rol.l 16,WB
- WA=WA and 255 : WB=WB and 255 : WC=WC and 65535
- A$="x="+Str$(WB)+",y="+Str$(WA)
- If INST=CEND
- Print #1,Hex$(INST);": CEND";N$;
- Else
- If Btst(0,WC) : C$="SKIP" Else C$="WAIT" : End If
- Print #1,Hex$(INST);": ";C$;" ";A$-" "+" (mask="+(Hex$(WC)-" ")+")";N$;
- End If
- Else
- MA=INST : MB=INST : Rol.l 16,MA
- MA=MA and 65535 : MB=MB and 65535
- NAMEREG[MA] : MA$=Param$
- If MA$=""
- Print #1,Hex$(INST,8);": MOVE #";Hex$(MB);",";Hex$(MA);N$;
- Else
- Print #1,Hex$(INST,8);": MOVE #";Hex$(MB);",";MA$;N$;
- End If
- End If
- Until INST=CEND
- Close 1
- End Proc
- Procedure FINDMAINCOP
- ' gets main copper address
- '
- Copper Off
- ADR=Cop Logic
- Copper On
- End Proc[ADR]
- Procedure COPSAVE[COPLIST,FILENAME$]
- ' saves off a copperlist
- '
- CEND=$FFFFFFFE : CL=COPLIST
- ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
- If Leek(ADR)<>CEND Then Pop Proc
- Bsave FILENAME$,COPLIST To ADR+4
- End Proc
- Procedure FINDCOPVALUE[COPLIST,REG]
- ' gets the value a register is set to in the coplist (or -1 if not found)
- '
- CEND=$FFFFFFFE : CL=COPLIST
- REG=REG and %111111110
- ADR=CL-4 : Repeat : Add ADR,4 : Until Leek(ADR)=CEND or(ADR-CL)>151404
- If Leek(ADR)<>CEND Then Pop Proc
- NUM=-1
- Repeat : INST=Leek(CL) : Add CL,4 : If Btst(16,INST)=0 : A=INST
- Rol.l 16,A : A=A and %111111110 : If A=REG : NUM=INST and $FFFF : End If
- End If : Until INST=CEND or NUM<>-1
- End Proc[NUM]
- Procedure NAMEREG[REG]
- ' puts a name to a register (or "" if it doesn't exist)
- NAME$=""
- REG=REG/2
- If REG>255 Then Pop Proc
- Restore
- For A=0 To REG : Read NAME$ : Next A
- Rem Generated from V40 hardware/custom.i
- Data "bltddat","dmaconr","vposr","vhposr","dskdatr","joy0dat","joy1dat"
- Data "clxdat","adkconr","pot0dat","pot1dat","potinp","serdatr","dskbytr"
- Data "intenar","intreqr","dskpth","dskptl","dsklen","dskdat","refptr"
- Data "vposw","vhposw","copcon","serdat","serper","potgo","joytest","strequ"
- Data "strvbl","strhor","strlong","bltcon0","bltcon1","bltafwm","bltalwm"
- Data "bltcpth","bltcptl","bltbpth","bltbptl","bltapth","bltaptl","bltdpth"
- Data "bltdptl","bltsize","bltcon0l","bltsizv","bltsizh","bltcmod","bltbmod"
- Data "bltamod","bltdmod","","","","","bltcdat","bltbdat","bltadat",""
- Data "sprhdat","bplhdat","lisaid","dsksync","cop1lch","cop1lcl","cop2lch"
- Data "cop2lcl","copjmp1","copjmp2","copins","diwstrt","diwstop","ddfstrt"
- Data "ddfstop","dmacon","clxcon","intena","intreq","adkcon","aud0lch"
- Data "aud0lcl","aud0len","aud0per","aud0vol","aud0dat","","","aud1lch"
- Data "aud1lcl","aud1len","aud1per","aud1vol","aud1dat","","","aud2lch"
- Data "aud2lcl","aud2len","aud2per","aud2vol","aud2dat","","","aud3lch"
- Data "aud3lcl","aud3len","aud3per","aud3vol","aud3dat","","","bpl1pth"
- Data "bpl1ptl","bpl2pth","bpl2ptl","bpl3pth","bpl3ptl","bpl4pth","bpl4ptl"
- Data "bpl5pth","bpl5ptl","bpl6pth","bpl6ptl","bpl7pth","bpl7ptl","bpl8pth"
- Data "bpl8ptl","bplcon0","bplcon1","bplcon2","bplcon3","bpl1mod","bpl2mod"
- Data "bplcon4","clxcon2","bpl1dat","bpl2dat","bpl3dat","bpl4dat","bpl5dat"
- Data "bpl6dat","bpl7dat","bpl8dat","spr0pth","spr0ptl","spr1pth","spr1ptl"
- Data "spr2pth","spr2ptl","spr3pth","spr3ptl","spr4pth","spr4ptl","spr5pth"
- Data "spr5ptl","spr6pth","spr6ptl","spr7pth","spr7ptl","spr0pos","spr0ctl"
- Data "spr0data","spr0datb","spr1pos","spr1ctl","spr1data","spr1datb"
- Data "spr2pos","spr2ctl","spr2data","spr2datb","spr3pos","spr3ctl"
- Data "spr3data","spr3datb","spr4pos","spr4ctl","spr4data","spr4datb"
- Data "spr5pos","spr5ctl","spr5data","spr5datb","spr6pos","spr6ctl"
- Data "spr6data","spr6datb","spr7pos","spr7ctl","spr7data","spr7datb"
- Data "color00","color01","color02","color03","color04","color05","color06"
- Data "color07","color08","color09","color10","color11","color12","color13"
- Data "color14","color15","color16","color17","color18","color19","color20"
- Data "color21","color22","color23","color24","color25","color26","color27"
- Data "color28","color29","color30","color31","htotal","hsstop","hbstrt"
- Data "hbstop","vtotal","vsstop","vbstrt","vbstop","sprhstrt","sprhstop"
- Data "bplhstrt","bplhstop","hhposw","hhposr","beamcon0","hsstrt","vsstrt"
- Data "hcenter","diwhigh","bplhmod","sprhpth","sprhptl","bplhpth","bplhptl"
- Data "","","","","","","fmode","noop"
- End Proc[NAME$]